<?php

use Faker\Factory as Faker;
use App\Models\ReturnLog;
use App\Repositories\ReturnLogRepository;

trait MakeReturnLogTrait
{
    /**
     * Create fake instance of ReturnLog and save it in database
     *
     * @param array $returnLogFields
     * @return ReturnLog
     */
    public function makeReturnLog($returnLogFields = [])
    {
        /** @var ReturnLogRepository $returnLogRepo */
        $returnLogRepo = App::make(ReturnLogRepository::class);
        $theme = $this->fakeReturnLogData($returnLogFields);
        return $returnLogRepo->create($theme);
    }

    /**
     * Get fake instance of ReturnLog
     *
     * @param array $returnLogFields
     * @return ReturnLog
     */
    public function fakeReturnLog($returnLogFields = [])
    {
        return new ReturnLog($this->fakeReturnLogData($returnLogFields));
    }

    /**
     * Get fake data of ReturnLog
     *
     * @param array $postFields
     * @return array
     */
    public function fakeReturnLogData($returnLogFields = [])
    {
        $fake = Faker::create();

        return array_merge([
            'type' => $fake->randomDigitNotNull,
            'order_id' => $fake->randomDigitNotNull,
            'goods_id' => $fake->randomDigitNotNull,
            'attribute_id' => $fake->randomDigitNotNull,
            'status' => $fake->randomDigitNotNull,
            'created_at' => $fake->word,
            'updated_at' => $fake->word
        ], $returnLogFields);
    }
}
